/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

// System headers required for setgroups, etc.
#include <sys/types.h>
#include <unistd.h>
#include <grp.h>

#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>

#include <AudioFlinger.h>
#include <CameraService.h>
#include <MediaPlayerService.h>
#include <AudioPolicyService.h>
#include <private/android_filesystem_config.h>

using namespace android;

int main(int argc, char** argv)
{
    sp<ProcessState> proc(ProcessState::self());		// 获取ProcessState实例，并赋给proc变量
    sp<IServiceManager> sm = defaultServiceManager();		// 获取ServiceManager的远程代理接口，defaultServiceManager函数定义在IServiceManager.cpp文件中
    LOGI("ServiceManager: %p", sm.get());
    AudioFlinger::instantiate();			// 初始化AudioFlinger
    MediaPlayerService::instantiate();		// 初始化MediaPlayerService
    CameraService::instantiate();			// 初始化CameraService
    AudioPolicyService::instantiate();		// 初始化AudioPolicyService
    ProcessState::self()->startThreadPool();		// 启动线程池
    IPCThreadState::self()->joinThreadPool();		// 将主线程加入线程池中
}
